home *** CD-ROM | disk | FTP | other *** search
/ Minami 78 / MINAMI78.iso / Extra / winamp53.exe / $R0 / Winamp Modern / scripts / mute.m < prev    next >
Text File  |  2005-09-15  |  3KB  |  114 lines

  1. #include <lib/std.mi>
  2.  
  3. Function updateVolume(int v);
  4.  
  5. Global Group frameGroup;
  6. Global Togglebutton MuteBtn,MuteBtnShade;
  7. Global Timer SongTickerTimer;
  8. Global Text SongTicker;
  9. Global Float VolumeLevel;
  10. Global Boolean Muted,BtnPressed;
  11. Global Layer volumebar;
  12. Global Timer callback;
  13.  
  14. System.onScriptLoaded() { 
  15.     Muted = getPrivateInt("winamp5", "muted", 0);
  16.     VolumeLevel = getPrivateInt("winamp5", "old_volume", 0);
  17.     frameGroup = getScriptGroup();
  18.  
  19.     MuteBtn = frameGroup.findObject("mute");
  20.     MuteBtn.setActivated(Muted);
  21.  
  22.     callback = new Timer; callback.setDelay(5); callback.start();
  23.     SongTicker = frameGroup.findObject("songticker");
  24.  
  25.     volumebar = frameGroup.findObject("volumebar");
  26.     volumebar.setXmlParam("w",integertostring( (system.getVolume()/255) *70 + 5));
  27.  
  28.     SongTickerTimer = new Timer;
  29.     SongTickerTimer.setDelay(1000);
  30.     if (Muted) {
  31.         SongTickerTimer.start();
  32.         SongTicker.setText("Mute ON");
  33.     }
  34.     BtnPressed = 0;
  35. }
  36.  
  37.  
  38. System.onScriptUnloading() {
  39.     setPrivateInt("winamp5", "muted", Muted);
  40.     setPrivateInt("winamp5", "old_volume", VolumeLevel);
  41.     delete callback;
  42. }
  43.  
  44. callback.onTimer() {
  45.     MuteBtnShade = getcontainer("main").getlayout("shade").findObject("shademute");
  46.     if (MuteBtnShade != NULL) {
  47.         MuteBtnShade.setActivated(Muted);
  48.         stop();
  49.     }
  50. }
  51.  
  52. SongTickerTimer.onTimer() {
  53.     SongTicker.setText("");
  54.     SongTickerTimer.stop();
  55. }
  56.  
  57. MuteBtn.onLeftClick() {
  58.     BtnPressed = 1;
  59.     if (!Muted) {
  60.         VolumeLevel = System.getVolume();
  61.         System.setVolume(0);
  62.         Muted = 1;
  63.         SongTickerTimer.start();
  64.         SongTicker.setText("Mute ON");
  65.         MuteBtnShade.setActivated(1);
  66.     } else {
  67.         System.setVolume(VolumeLevel);
  68.         Muted = 0;
  69.         SongTickerTimer.start();
  70.         SongTicker.setText("Mute OFF");
  71.         MuteBtnShade.setActivated(0);
  72.     }
  73. }
  74.  
  75. MuteBtnShade.onLeftClick() {
  76.     BtnPressed = 1;
  77.     if (!Muted) {
  78.         VolumeLevel = System.getVolume();
  79.         System.setVolume(0);
  80.         Muted = 1;
  81.         SongTickerTimer.start();
  82.         SongTicker.setText("Mute ON");
  83.         MuteBtn.setActivated(1);
  84.     } else {
  85.         System.setVolume(VolumeLevel);
  86.         Muted = 0;
  87.         SongTickerTimer.start();
  88.         SongTicker.setText("Mute OFF");
  89.         MuteBtn.setActivated(0);
  90.     }
  91. }
  92.  
  93. System.onScriptUnloading() {
  94.     delete SongTickerTimer;
  95. }
  96.  
  97. System.onvolumechanged(int newvol)
  98. {
  99.     volumebar.setXmlParam("w",integertostring( (newvol/255) *70 + 5));
  100.     if (!BtnPressed) {
  101.         SongTickerTimer.start();
  102.         SongTicker.setText("Volume:" + System.integerToString(newvol/2.55) + "%");
  103.  
  104.         if (Muted) {
  105.             MuteBtn.setActivated(0);
  106.             MuteBtnShade.setActivated(0);
  107.             Muted = 0;
  108.         }
  109.     }
  110.     BtnPressed = 0;
  111. }
  112.  
  113.  
  114.